<div class="block-news">
<?
$parname = getRecord('xteam_category','id='.$id);
if($parname){
    $per_page = 18;
    $page_no = $p-1<=0 ? 0 : $p-1;
    $first = ($page_no) * $per_page;
    $limit = $first . ',' . $per_page;
    $products = getArray('xteam_product','status=1 AND parent_id='.$id,$limit,'is_hot DESC,date_added DESC, sort ASC');
    $list_pro = getArray('xteam_product','parent_id='.$id);
    if($list_pro) $total = count($list_pro);
    $col=0;
    foreach ($products as $product){
        $properties = product_properties($product['id']);
        ++$col;
        if($parid[$product['parent_id']]%2==0){$class_sp="rental";}else{$class_sp="salse";}
        $class = $col%2!=0? 'block-left' : 'block-right';?>
        <div class="<?=$class?>">
            <h2 class="title-news">
                <?=$product['is_hot']==1?'<img src="'.$curHost.'images/hot.gif" alt="'.utf8_to_ascii($product['name']).'" />':''?>
                <a href="<?=$curHost.utf8_to_ascii($parseokey[$product['parent_id']]!=''?$parseokey[$product['parent_id']]:$parname[$product['parent_id']]).'/'.utf8_to_ascii($parseokey[$product['parent_id']]!=''?$parseokey[$product['parent_id']]:$parname[$product['parent_id']])?>/7/<?=$parid[$product['parent_id']]?>.html">
                    <span class="<?=$class_sp?>"><?=$parname['name']?> | </span>
                </a>
                <a href="<?=$curHost.utf8_to_ascii($parseokey[$product['parent_id']]!=''?$parseokey[$product['parent_id']]:$parname[$product['parent_id']])?>/<?=utf8_to_ascii($product['seo_key']!=''?$product['seo_key']:$product['name'])?>/1/<?=$product['id']?>.html" title="<?=$product['name']?>">
                    <?=$product['name']?>
                </a>
            </h2>
            <? if($product['image_thumbs']!=''){?>
            <a href="<?=$curHost.utf8_to_ascii($parseokey[$product['parent_id']]!=''?$parseokey[$product['parent_id']]:$parname[$product['parent_id']])?>/<?=utf8_to_ascii($product['seo_key']!=''?$product['seo_key']:$product['name'])?>/1/<?=$product['id']?>.html" title="<?=$product['name']?>">
                <img src="<?=$curHost.$product['image_thumbs']?>" alt="<?=$product['seo_key'].'-'.$product['name']?>" class="img-news" title="<?=$product['name']?>" />
            </a>
            <? }else{?>
            <a href="<?=$curHost.$parent=$parseokey[$product['parent_id']]!=''?$parseokey[$product['parent_id']]:utf8_to_ascii($parname[$product['parent_id']])?>/<?=str_replace(array('--','--'), '-', utf8_to_ascii($name=$product['seo_key']!=''?$product['seo_key']:$product['name']))?>/1/<?=$product['id']?>.html" title="<?=$product['name']?>">
                <img src="<?=$curHost?>images/no_image.gif" alt="<?=$product['seo_key']." - ".$product["name"]?>"  class="img-news" style="display: inline;" title="<?=$product['name']?>" />
            </a>
            <? }?>
            <div class="short-news">
                <ul>
                <?
                if($properties){
                    foreach($properties as $prop){?>
                    <li><label><?=$prop['cat']?>:&nbsp;</label><span><?=$prop['name']?></span></li>
                <?
                    }
                }else{?>
                    <li><label>đang cập nhật</label></li>
                <? }?>
                </ul>
            </div>
        </div>
    <?  if($col%2==0 || $col>=count($products)){echo '<div class="clear"></div></div><div class="block-news">';}
    }?>
        <div class="clear"></div>
    </div>
    <script language="javascript" type="text/javascript">
        $(document).ready(function(){
            var contentdiv = $('.block-news').text(function(){
                if ($.trim($(this).text())==''){
                    $(this).hide();
                }
                });
        })
    </script>
    <?
    $rowPage = $_lang=="vn" ? "Sản phẩm" : "Products";
    $pagePage = $_lang=="vn" ? "Trang" : "Page";
    if($_lang=="vn"){
        $$rowPage       = "Sản phẩm";
        $pagePage       = "Trang";
        $titleFirst 	= "&laquo;";
        $titlePrevious 	= "&lsaquo;";
        $titleNext 	= "&rsaquo;";
        $titleLast 	= "&raquo;";
    }else if($_lang=="en"){
        $rowPage = "Products";
        $pagePage 	= "Page";
        $titleFirst 	= "First";
        $titlePrevious 	= "Previous";
        $titleNext 	= "Next";
        $titleLast 	= "Last";
    }else{
        $rowPage = "新聞";
        $pagePage 	= "頁";
        $titleFirst 	= "首先";
        $titlePrevious 	= "上一頁";
        $titleNext 	= "下一頁";
        $titleLast 	= "最後";
    }
//    $pages_no = countPages($total,$per_page);
    if($total>$per_page || $page_no>0){
    ?>
    <div class="pagging">
        <ul class="page-numbers">
            <? if($p!='' && $p>1){?>
                <? //if(){?>
                <li><a title="<?=$titleFirst?>" id="first" href="<?=$curHost.utf8_to_ascii($_GET['cat'])?>/<?=utf8_to_ascii($_REQUEST['ali'])?>/7/<?=$id?>/page-1.html"><?=$titleFirst?></a></li>
                <li><a title="<?=$titlePrevious?>" id="previous" href="<?=$curHost.utf8_to_ascii($_GET['cat'])?>/<?=utf8_to_ascii($_REQUEST['ali'])?>/7/<?=$id?>/page-<? if($p-1<0){echo $p=1;}else{echo $p-1;}?>.html"><?=$titlePrevious?></a></li>
                <? //}?>
            <? }?>
            <? $from=($p-10>0?$p-10:0); $to=($p+10<$pages_no?$p+10:$pages_no);
            for ($i=$from;$i<$to;$i++){
                if ($i+1!=$p && $i+1>0) {?>
                    <li><a href="<?=$curHost.utf8_to_ascii($_GET['cat'])?>/<?=utf8_to_ascii($_REQUEST['ali'])?>/7/<?=$id?>/page-<?=$i+1?>.html"><?=$i+1?></a></li>
            <? }else{?>
                    <li><a class="active"><?=($i+1)?></a></li>
            <? }
            }?>
            <? if($pages_no>0 && $p<$pages_no){?>
                <li><a title="<?=$titleNext?>" id="next" href="<?=$curHost.utf8_to_ascii($_GET['cat'])?>/<?=utf8_to_ascii($_REQUEST['ali'])?>/7/<?=$id?>/page-<? if($p+1>$pages_no){echo $p=$pages_no;}else{if($p==''){echo $p+2;}else{echo $p+1;}}?>.html"><?=$titleNext?></a></li>
                <li><a title="<?=$titleLast?>" id="last" href="<?=$curHost.utf8_to_ascii($_GET['cat'])?>/<?=utf8_to_ascii($_REQUEST['ali'])?>/7/<?=$id?>/page-<? if($p+1>$pages_no){echo $p=$pages_no;}else{echo $pages_no;}?>.html"><?=$titleLast?></a></li>
            <? }?>
        </ul>
    </div>
    <? }
}else{
    require_once 'modules/error.php';
}?>